using PluginFrame;

namespace PcrExperimentProject
{
	public class FormProgramEditor : FormProjectEditor
	{
		public FormProgramEditor(IApplication application, IPcrExperimentProject pcrExperimentProject, bool isNewPcrProject, bool isAllowToChangeChannelSettings)
			: base(application, pcrExperimentProject, isNewPcrProject, isAllowToChangeChannelSettings)
		{
			btnOption.Enabled = false;
			btnPassword.Enabled = false;
			tabPcrProject.Tabs["Analysis Option"].Enabled = false;
			tabPcrProject.Tabs["Rule"].Enabled = false;
			tabPcrProject.Tabs["Cross Talk"].Enabled = false;
		}

		protected override void SaveProject()
		{
			if (mIsNewPcrProject)
			{
				mMenuFile.DropDownItems["SaveAsProjectFile"].PerformClick();
			}
			else
			{
				if (!SaveMeltingSegment())
				{
					return;
				}
				for (int i = 0; i < tabAmplification.Tabs.Count; i++)
				{
					if (tabAmplification.Tabs[i].Visible && !CheckAmplificationSegment(i))
					{
						return;
					}
				}
				if (mIsSegmentPositionChanged)
				{
					mPcrExperimentProject.PcrProgram.AmplificationSegments = GenerateAmplificationSegements();
				}
				if (CheckProgramFluorescenceDetection())
				{
					mIsSaved = true;
					mIsRefreshSavedFile = true;
				}
			}
		}
	}
}
